import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'
import { UserListComponent } from './list/list.component'
import { UserProfileComponent } from '@shared/components/user-profile/user-profile.component'
import { UserNewComponent } from './new/new.component'
import { EditPasswordComponent } from '../../shared/components/edit-password/edit-password.component'
import { UserSystemComponent } from '@shared/components/user-profile/tabs/system/user-system.component'
import { UserAuditComponent } from '@shared/components/user-profile/tabs/audit/user-audit.component'
import { ListReuseGuardClass } from '@shared/classes/ListReuseGuardClass';

const routes: Routes = [
  { path: '', redirectTo: 'list', component: UserListComponent, pathMatch: 'full' },
  {
    path: 'list',
    component: UserListComponent,
    pathMatch: 'full',
    canActivate: [ListReuseGuardClass],
    data: {
      title: '用户列表',
      titleI18n: 'MENU.USER.LIST',
      reuse: true,
    },
  },
  {
    path: 'new',
    component: UserNewComponent,
    data: {
      breadcrumb: 'USER.BTN.CREATE',
      titleI18n: 'USER.TITLE.CREATE',
    },
  },
  {
    path: ':id',
    component: UserProfileComponent,
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.DETAIL',
      titleI18n: 'USER.TITLE.DETAIL',
    },
    children: [
      {
        path: '', redirectTo: 'system', pathMatch: 'full',
      },
      {
        path: 'system',
        component: UserSystemComponent,
        data: { titleI18n: 'DASHBOARD.TITLE.PROFILE' },
      },
      {
        path: 'audit',
        component: UserAuditComponent,
        data: { titleI18n: 'DASHBOARD.TITLE.PROFILE' },
      }
    ]
  },
  {
    path: ':id/edit-password',
    component: EditPasswordComponent,
    data: {
      breadcrumb: 'USER.TITLE.CHANGE_PASSWORD',
      titleI18n: 'USER.TITLE.CHANGE_PASSWORD',
    },
  }
]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class UserRoutingModule { }
